package com.t174.car.controller;

import com.t174.car.dao.CarSalesDao;
import com.t174.car.entity.CarSales;
import com.t174.car.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/carsales")
@Scope("prototype")
public class CarSalesController {
    @Autowired
    private CarSalesDao carSalesDao;
    @Autowired
    private CarService carService;
    @RequestMapping("/query")
    @ResponseBody
    public List<CarSales> query(){ return carSalesDao.query(); }
    @RequestMapping("/sales")
    @ResponseBody
    public int salesCar(CarSales carSales){
        return carService.salesCar(carSales);
    }
    @RequestMapping("/queryByGid")
    @ResponseBody
    public List<CarSales> query(int id){ return carSalesDao.queryByGid(id); }
}
